Integrate signal 您所在的位置:网站首页 simulink integrator limited Integrate signal

Integrate signal

2024-06-11 05:39| 来源: 网络整理| 查看: 265

Open Live Script

You can use the state port to prevent creating an algebraic loop when you need an Integrator block in one enabled subsystem to use the state of an Integrator block in another enabled subsystem.

Open the model EnabledSubsystemStatesAlgLoop. The model contains two enabled subsystems, A and B. A Constant block provides the first input to each subsystem. The output from subsystem A is the other input for subsystem B. The output from subsystem B is the other input for subsystem A. A Pulse block provides the enable signal for both subsystems. The Pulse block enables subsystem B directly. The Pulse block output is inverted using a Logical Operator block to create the enable signal for subsystem A. As a result, the execution of the enabled subsystems alternates between subsystem A and subsystem B as the value of the Pulse block output changes.

mdl = "EnabledSubsystemStatesAlgLoop"; open_system(mdl);

The enabled subsystems each contain an Integrator block that uses an input port to provide the initial condition for the block. The Enable block in each subsystem is configured to reset the states each time the subsystem executes. When the state of the Integrator block resets, the initial value comes from the initial condition input port, which is connected to the output of the Integrator block in the other subsystem. Passing the state from one subsystem to another allows for continual integration of the signal while alternating execution between the subsystems.

However, to compute the output value from subsystem B, the solver needs the output from subsystem A and vice versa. Connecting the output of one Integrator block to the input of the other creates an algebraic loop. To see the loop in the model, use the Simulink.BlockDiagram.getAlgebraicLoops function. The Algebraic Loops viewer opens and shows that the model contains one real algebraic loop.

Simulink.BlockDiagram.getAlgebraicLoops(mdl);

The algebraic loop is highlighted in the model.

To avoid creating this algebraic loop, you can use the state port instead of the output port to pass the state of the Integrator block in one subsystem to the initial condition of the Integrator block in the other. The solver computes the block state value at an earlier point in each time step, so the output for subsystem B no longer depends on the output from subsystem A and vice versa.

To see this solution, open the model EnabledSubsystemStates. The input, enable, and output signals are the same, but the output from subsystem A no longer acts as a second input for subsystem B and vice versa.

mdl2 = "EnabledSubsystemStates"; open_system(mdl2)

The software does not support connecting the state port of the Integrator block to an output port on an enabled subsystem. The state port of the Integrator block in subsystem A is connected to the initial condition port for the Integrator block in subsystem B using GoTo and From blocks with global visibility. The state port of the Integrator block in subsystem B connects to the initial condition port for the Integrator block in subsystem A using the same strategy.

To verify that using the state port resolved the algebraic loop, use the Simulink.BlockDiagram.getAlgebraicLoops function again.

Simulink.BlockDiagram.getAlgebraicLoops(mdl2);No algebraic loops were found.

Simulate the model. To view the results, double-click the Scope block. The Scope window displays the enable signal and the output signals from each subsystem.

out = sim(mdl2);

For another example of a system that passes state values between enabled subsystems, see Building a Clutch Lock-Up Model.



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有